//
//  YLViewController.m
//  YLBanner
//
//  Created by geoegeleung on 03/16/2018.
//  Copyright (c) 2018 geoegeleung. All rights reserved.
//

#import "YLViewController.h"
#import "YLBannerView.h"
@interface YLViewController ()<YLBannerViewDelegate>
@property (nonatomic,strong)YLBannerView *bannerView;
@end

@implementation YLViewController
-(YLBannerView *)bannerView{
    if (!_bannerView) {
        YLBannerView *bannerView = [[YLBannerView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 180)];
        bannerView.delegate = self;
        _bannerView = bannerView;
    }
    return _bannerView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self.view addSubview:self.bannerView];
    [self loadBanner];
}

- (void)loadBanner{
    
    NSArray *urls = @[@"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1481331159,2901051424&fm=27&gp=0.jpg",
                      @"https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=222615259,2947254622&fm=27&gp=0.jpg",
                      @"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1521178325707&di=e302d6139ab597587409ec4d8b9e5853&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimage%2Fc0%253Dshijue1%252C0%252C0%252C294%252C40%2Fsign%3D7b941e0eb3389b502cf2e811ed5c8fa8%2F4ec2d5628535e5ddaa54a1cf7cc6a7efce1b62a1.jpg",
                      @"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1521178325707&di=c8cfd93fec5f89742249ee5534784595&imgtype=0&src=http%3A%2F%2Fpic15.nipic.com%2F20110803%2F7180732_211822337168_2.jpg",
                      ];
    NSMutableArray *temp = [[NSMutableArray alloc] init];
    for(NSInteger i = 0; i < urls.count;i++){
        YLImageModel *model = [[YLImageModel alloc] init];
        model.imageURL = urls[i];
        [temp addObject:model];
    }
    self.bannerView.dataArray = temp;
}


#pragma mark - YLBannerViewDelegate
-(void)bannerView:(YLBannerView *)view didClickPage:(NSInteger)index{
    //点击banner
    NSLog(@"点击 %ld",index);
}

@end


